Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lowercase input before bech32 encoding #378

Merged
merged 6 commits into from
Oct 29, 2019
Merged

lowercase input before bech32 encoding #378

merged 6 commits into from
Oct 29, 2019

Conversation

pavel-main
Copy link
Contributor

fixes #375

Quick shortcut for testing:

$ stack test --test-arguments "--match=bech32"

@runeksvendsen
Copy link
Contributor

runeksvendsen commented Oct 27, 2019

In my opinion, if uppercase text is not defined for a human-readable representation of a bech32 address, then the data type used to represent this should not be able to contain uppercase characters. So, instead of using a type synonym type HRP = Text, we should use a newtype with a smart contractor that performs any necessary conversions (such as lower-casing) upon construction. This avoids requiring that every function, that takes a HRP as an argument, do this manually.

@jprupp
Copy link
Member

jprupp commented Oct 27, 2019

Technically the HRP is defined as case-insensitive, but there is nothing to prevent it from being case-preserving, so it seems correct to me to use Text instead of a custom type.

@jprupp jprupp merged commit b776b05 into haskoin:master Oct 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bech32Encode generates invalid output if the HRP contains upper case characters.
4 participants